package stbu;


import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.SessionAttribute;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.servlet.ModelAndView;
import stbu.bean.User;

import java.util.Date;

@Controller
@SessionAttributes(names = {"regDate"},types = {User.class})
@RequestMapping("/user")
public class UserController {

    @RequestMapping("/toReg")
    public String toReg() {
        return "reg";
    }
    public String reg(@RequestParam("username")String u1,
                      @RequestParam("pwd")String password, Model model){
        User user = new User();
        user.setUsername(u1);
        user.setPassword(password);
        Date regData = new Date();
        model.addAttribute("regDate",regData);
        model.addAttribute("user",user);
        return "forword:toLogin";
    }
}
